package com.bw.mapper;

import com.bw.bean.Vo;
import com.bw.bean.Vo1;
import com.bw.bean.Vo2;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper

public interface VoMapper {

    @Select("select bp.name,sum(oi.total_amount) `value` from order_info oi\n" +
            "left join base_province bp on oi.province_id = bp.id\n" +
            "group by bp.name;\n")
    List<Vo> getList1();

    @Select("select  bt.tm_name `name`, sum(oi.total_amount)  `value`\n" +
            "from  order_info oi\n" +
            "left  join  order_detail od on  oi.id=od.order_id\n" +
            "left  join  sku_info si on si.id=od.sku_id\n" +
            "left  join   base_trademark bt  on bt.id=si.tm_id\n" +
            "group by bt.tm_name\n" +
            "order by sum(oi.total_amount) desc")
    List<Vo> getList2();

    @Select("SELECT b1.id,b1.name,sum(od.sku_num*od.order_price)/(select sum(sku_num*order_price)from order_detail) `value`\n" +
            "FROM order_detail od\n" +
            "left join sku_info s on od.sku_id=s.id\n" +
            "left join base_category3  b3 on b3.id=s.category3_id\n" +
            "left join base_category2  b2 on b2.id=b3.category2_id\n" +
            "left join base_category1  b1 on b1.id=b2.category1_id\n" +
            "GROUP BY b1.id,b1.name;")
    List<Vo1> getList3();


    @Select("select  is_new  `newold`,count(1) `num`,sum(pv_ct)  `sum`,SUM(dur_sum)/SUM(pv_ct) `avgtime`,sum(pv_ct)  /count(1)  `avgnum`,sum(jump_sum)/sum(pv_ct)  `avg`\n" +
            "from anew_page_view_window\n" +
            "group by  is_new;")
    List<Vo2> getList4();
}
